﻿using MovingChame.WindowsStoreApp.Common;
using MovingChameLibrary.Models;
using MovingChameLibrary;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using MovingChameLibrary.Models.Action;
using MovingChameLibrary.ViewModels;
using MovingChameLibrary.PersonalDataManager;

namespace MovingChame.WindowsStoreApp.UIModule
{
    public sealed partial class TourSelectionPage : LayoutAwarePage
    {
        private TourSelectionViewModel _viewModel;
        public TourSelectionViewModel ViewModel
        {
            get { return this._viewModel; }
            set
            {
                this._viewModel = value;
                this.DataContext = value;
            }
        }

        public TourSelectionPage()
        {
            this.InitializeComponent();
        }

        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            var tourDataGroups = PersonalTourData.GetItem((int)navigationParameter);
            ViewModel = new TourSelectionViewModel(tourDataGroups.Items);
            pageTitle.Text = tourDataGroups.Title;
        }

        void ItemView_ItemClick(object sender, ItemClickEventArgs e)
        {
            Tour tour = (Tour)e.ClickedItem;
            this.Frame.Navigate(typeof(TourOverviewPage), tour.Id);
        }
    }
}